#include <cstdio>
#include <queue>
typedef double lb;
const int N = 3005, M = 10005;
int n, m;
struct Edge {
	int v, nxt;
	lb c;
} e[M];
int cnt, heads[N], tot[N];
lb dis[N];
inline void add(int u, int v, double c) {
	e[++cnt].nxt = heads[u];
	e[cnt].v = v;
	e[cnt].c = c;
	heads[u] = cnt;
}
inline lb abs(lb x) { return x < 0.0 ? -x : x; }
inline lb min(lb a, lb b) { return a < b ? a : b; }
bool vis[N];
std::queue< int > q;
inline bool chk(lb val) {
	while (!q.empty()) q.pop();
	for (int i = 1; i <= n; ++i) { vis[i] = false, dis[i] = 1e10, tot[i] = 0; }
	dis[1] = 0, ++tot[1], vis[1] = true;
	q.push(1);
	while (!q.empty()) {
		int u = q.front();
		vis[u] = false;
		q.pop();
		for (int i = heads[u]; i; i = e[i].nxt) {
			int v = e[i].v;
			if (dis[v] > dis[u] + e[i].c - val) {
				if (++tot[v] > 25) { return true; }
				dis[v] = dis[u] + e[i].c - val;
				if (!vis[v]) {
					vis[v] = true;
					q.push(v);
				}
			}
		}
	}
	return false;
}
int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
	freopen("testdata.in", "r", stdin);
	freopen("testdata.out", "w", stdout);
#endif
#ifndef LOCAL
	freopen("circle.in", "r", stdin);
	freopen("circle.out", "w", stdout);
#endif
#endif

	scanf("%d%d", &n, &m);
	int a, b;
	lb c;
	for (int i = 1; i <= m; ++i) {
		scanf("%d%d%lf", &a, &b, &c);
		add(a, b, c);
	}
	lb l = -1e6, r = 1e6, mid;
	while (abs(r - l) > 1e-9) {
		mid = (l + r) / 2;
		if (chk(mid)) {
			r = mid;
		} else
			l = mid;
	}
	printf("%.8lf", l);
	return 0;
}